# Maintainer: Christian Hesse <mail@eworm.de>

pkgname=antlr4-runtime
pkgver=4.11.1
pkgrel=1
pkgdesc='Antlr C++ runtime'
url='https://www.antlr.org/'
arch=('loong64' 'x86_64')
depends=('gcc-libs')
makedepends=('git' 'cmake' 'python')
license=('BSD')
source=("https://www.antlr.org/download/antlr4-cpp-runtime-${pkgver}-source.zip")
sha256sums=('8018c335316e61bb768e5bd4a743a9303070af4e1a8577fa902cd053c17249da')
# FS#72726
options=(staticlibs)

build() {
  export CFLAGS+=' -ffat-lto-objects'
  export CXXFLAGS+=' -ffat-lto-objects'

  mkdir build
  cd build
  cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_STANDARD=17 \
    -DANTLR4_INSTALL=ON \
    -DINSTALL_GTEST=OFF
  make
}

package() {
  cd build
  make DESTDIR="${pkgdir}/" install
  install -Dm644 "${srcdir}"/LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}"/LICENSE
}
